<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />

    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">

    </ex_super_table_page>
    <ex_super_dialog_form ref="detailDialog" v-bind="detail_dialog" noSubmit>
    </ex_super_dialog_form>
    <ex_super_dialog_form ref="deviationHandlerDialog" v-bind="deviation_handler_dialog" @afterSubmitSuccess="reload()">
    </ex_super_dialog_form>
  </div>
</template>
<script>

import business_function from "@/common/business_function"

import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import emitOnFunction from '@/mixin/emit-on-function';
let emitKey = 'oms>sku_measure_deviation'
export default {
  title: 'label_sku_measure_deviation',
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage,],
  components: {},
  data() {
    return {
      selection: [],
      selectStatusCount: {},
      option: {
        search: {
          default: { status: "", },
          model: [
            { key: "customerId", label: "label_customer", type: 'common_customer_choose' },
            { key: "skuId", label: "label_sku", type: 'sku_selec_input' },
            { key: "receivingOrderCode", label: "label_inbound_code"},
            { key: "disposeStatus", label: "label_status", type: 'select', enum: "SkuDifferenceStatusEnum" },
            { key: "disposeUserId", label: "label_handler_user", type: 'common_user_select', },
            {
              key: 'startDisposeTime', label: 'label_start_handler_time', type: 'date-picker',
              attrs: { type: "datetime", 'default-time': '00:00:00' },
            },
            {
              key: 'endDisposeTime', label: 'label_end_handler_time', type: 'date-picker',
              attrs: { type: "datetime", 'default-time': '23:59:59' },
            },
          ],
        },
        actionExtra: [
          {
            label: 'label_export', auth: 'oms_sku_measure_deviation_export', click: this.exportExcel
          },
        ],
        table: {
          url: "/oms-api/anomaly/OmsBaseSkuDifferenceRpc/selectPage.json",
          model: this.init_table_model(),
        }
      },
      detail_dialog: {
        customClass: 'dialog_auto',
        detailUrl: "/oms-api/anomaly/OmsBaseSkuDifferenceRpc/selectDetail.json",
        form: {
          itemClass: "form_item_default", inputClass: "form_input_default",
          formClass: "form_default_col2 flex_row_wrap",
          default: {attachedList:[],},
          model: [
            { key: 'receivingOrderCode', label: 'label_inbound_code', formType: 'text', },

            {
              key: 'customerName', label: 'label_customer_name', formType: 'text',
              formatter: (r, c, v) => this.$formatNameCode(v, r.customerCode)
            },

            {
              grid: [[
                {
                  span: 12,
                  col: {
                    grid: [
                      [{ key: 'skuName', label: 'label_sku_name', formType: 'text', },],
                      [{ key: 'skuOnlyCode', label: 'label_sku_only_code', formType: 'text', },],
                      [{ key: 'deviationRate', label: 'label_record_deviation_rate', formType: 'text',formatter: (r, c, v, i) => this.$addUnit(v ? v : "0", "%") },],
                    ]
                  },
                },
                {
                  span: 12,
                  col: {
                    key: 'dimension',
                    label: 'label_filing_dimension', 'width': 220, render: (h, { data }) => {
                      if ([data.skuWeight, data.skuLength, data.skuWidth, data.skuHeight].every(it => !it)) return this.$renderText(h, null)
                      return (<div>
                        <div>{this.$tt("label_weight") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuWeight, 3), "kg"))}</div>
                        <div>{this.$tt("label_length") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuLength, 2), "cm"))}</div>
                        <div>{this.$tt("label_width") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuWidth, 2), "cm"))}</div>
                        <div>{this.$tt("label_height") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuHeight, 2), "cm"))}</div>
                        <div>{this.$tt("label_volume") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuVolume, 3), "m³"))}</div>
                      </div>)
                    }
                  },
                },]
              ],
            },
            { divider: true },
            {
              grid: [[
                {
                  span: 12,
                  col: {
                    grid: [
                      [{
                        key: 'isTransitMeasure', label: 'label_is_transfer_measure', formType: 'text',
                        formatter: (r, c, v, i) => this.$enumShow(v ? v : "N", "YesOrNoEnum")
                      }],
                      [{
                        key: 'transitMeasureTime', label: 'label_transfer_measure_time', formType: 'text',
                        if: (data) => data.isTransitMeasure == "Y",
                        formatter: (r, c, v, i) => this.$dateFormat(v)
                      }],
                      [{
                        key: 'transitMeasureDeviationRate', label: 'label_transfer_measure_deviation_rate', formType: 'text',
                        if: (data) => data.isTransitMeasure == "Y",formatter: (r, c, v, i) => this.$addUnit(v ? v : "0", "%")
                      },],
                    ]
                  },
                },
                {
                  span: 12,
                  col: {
                    key: 'check_dimension', if: (data) => data.isTransitMeasure == "Y",
                    label: 'label_transfer_measure_dimen', 'width': 220, render: (h, { data }) => {
                      if ([data.transitMeasureSkuWeight, data.transitMeasureSkuLength, data.transitMeasureSkuWidth, data.transitMeasureSkuHeight].every(it => !it)) return this.$renderText(h, null)
                      return (<div>
                        <div>{this.$tt("label_weight") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuWeight, 3), "kg"))}</div>
                        <div>{this.$tt("label_length") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuLength, 2), "cm"))}</div>
                        <div>{this.$tt("label_width") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuWidth, 2), "cm"))}</div>
                        <div>{this.$tt("label_height") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuHeight, 2), "cm"))}</div>
                        <div>{this.$tt("label_volume") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuVolume, 3), "m³"))}</div>

                      </div>)
                    }
                  },
                },]
              ],
            },
            { divider: true, },
            {
              grid: [[
                {
                  span: 12,
                  col: {
                    grid: [
                      [{
                        key: 'isOverseasMeasure', label: 'label_is_standard_measure', formType: 'text',
                        formatter: (r, c, v, i) => this.$enumShow(v ? v : "N", "YesOrNoEnum")
                      }],
                      [{
                        key: 'overseasMeasureTime', label: 'label_standard_measure_time', formType: 'text', if: (data) => data.isOverseasMeasure == "Y",
                        formatter: (r, c, v, i) => this.$dateFormat(v)
                      }],
                      [{
                        key: 'overseasMeasureDeviationRate', label: 'label_standard_measure_deviation_rate', formType: 'text',
                        if: (data) => data.isOverseasMeasure == "Y",formatter: (r, c, v, i) => this.$addUnit(v ? v : "0", "%")
                      }],
                    ],
                  }
                },
                {
                  span: 12,
                  col: {
                    key: 'check_dimension', if: (data) => data.isOverseasMeasure == "Y",
                    label: 'label_standard_measure_dimen', 'width': 220, render: (h, { data }) => {
                      const row = data
                      if ([row.overseasMeasureSkuWeight, row.overseasMeasureSkuLength, row.overseasMeasureSkuWidth, row.overseasMeasureSkuHeight].every(it => !it)) return this.$renderText(h, null)
                      return (<div>
                           <div>{this.$tt("label_weight") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.overseasMeasureSkuWeight, 3), "kg"))}</div>
                        <div>{this.$tt("label_length") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.overseasMeasureSkuLength, 2), "cm"))}</div>
                        <div>{this.$tt("label_width") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.overseasMeasureSkuWidth, 2), "cm"))}</div>
                        <div>{this.$tt("label_height") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.overseasMeasureSkuHeight, 2), "cm"))}</div>
                        <div>{this.$tt("label_volume") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.overseasMeasureSkuVolume, 3), "m³"))}</div>


                      </div>)
                    }
                  },
                },]
              ],
            },
            { divider: true, },
            {
              key: 'disposeMode', label: 'label_do_with_method', formType: 'text',
              render: (h, { data, item }) => this.$renderText(h, this.$enumShow(data[item.key], "SkuDifferenceDisposeModeEnum"))

            },
            {
              key: 'coverMode', label: 'label_data_over_method', formType: 'text',
              render: (h, { data, item }) => this.$renderText(h, this.$enumShow(data[item.key], "SkuDifferenceCoverModeEnum"))

            },

            {
              key: 'disposeUserName', label: 'label_handler_user', formType: 'text',
              render: (h, { data, item }) => this.$renderText(h, (data[item.key]))

            },
            {
              key: 'disposeTime', label: 'label_handler_time', formType: 'text',
              render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

            },
            {
              key: 'attachedList', label: 'label_handler_attachment', type: 'ex_super_upload',
              attrs: {
                disabled: true,
                type: "file",
                limit: 10,
              }
            },
            { divider: true, },

            {
              key: 'confirmUserName', label: 'label_confirm_user', formType: 'text',

              render: (h, { data, item }) => this.$renderText(h, (data[item.key]))


            },
            {
              key: 'confirmTime', label: 'label_confirm_time', formType: 'text',
              render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

            },

            {
              key: 'closeUserName', label: 'label_close_user', formType: 'text',
              render: (h, { data, item }) => this.$renderText(h, (data[item.key]))

            },
            {
              key: 'closeTime', label: 'label_close_time', formType: 'text',
              render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

            },
          ],
        },
      },
      deviation_handler_dialog: {
        customClass: 'dialog_auto',
        submitUrl: "/oms-api/anomaly/OmsBaseSkuDifferenceRpc/dispose.json",
        submitDataHandle: (data) => {
          return {
            id: data.id,
            disposeMode: data.disposeMode,
            coverMode: data.coverMode,
            attachedList: data.attachedList,
          }
        },
        form: {
          itemClass: "form_item_default", inputClass: "form_input_default",
          formClass: "form_default_col2 flex_row_wrap",
          default: {attachedList:[],},
          model: [
            { key: 'receivingOrderCode', label: 'label_inbound_code', formType: 'text', },

            { key: 'customerName', label: 'label_customer_name', formType: 'text', },

            {
              grid: [[
                {
                  span: 12,
                  col: {
                    grid: [
                      [{ key: 'skuName', label: 'label_sku_name', formType: 'text', },],
                      [{ key: 'skuOnlyCode', label: 'label_sku_only_code', formType: 'text', },],
                      [{ key: 'deviationRate', label: 'label_record_deviation_rate', formType: 'text', formatter: (r, c, v, i) => this.$addUnit(v ? v : "0", "%")},],
                    ]
                  },
                },
                {
                  span: 12,
                  col: {
                    key: 'dimension',
                    label: 'label_filing_dimension', 'width': 220, render: (h, { data }) => {
                      if ([data.skuWeight, data.skuLength, data.skuWidth, data.skuHeight].every(it => !it)) return this.$renderText(h, null)
                      return (<div>
                        <div>{this.$tt("label_weight") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuWeight, 3), "kg"))}</div>
                        <div>{this.$tt("label_length") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuLength, 2), "cm"))}</div>
                        <div>{this.$tt("label_width") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuWidth, 2), "cm"))}</div>
                        <div>{this.$tt("label_height") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuHeight, 2), "cm"))}</div>
                        <div>{this.$tt("label_volume") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.skuVolume, 3), "m³"))}</div>
                      </div>)
                    }
                  },
                },]
              ],
            },

            { divider: true },


            {
              grid: [[
                {
                  span: 12,
                  col: {
                    grid: [
                      [{
                        key: 'isTransitMeasure', label: 'label_is_transfer_measure', formType: 'text',
                        formatter: (r, c, v, i) => this.$enumShow(v ? v : "N", "YesOrNoEnum")
                      }],
                      [{
                        key: 'transitMeasureTime', label: 'label_transfer_measure_time', formType: 'text',
                        if: (data) => data.isTransitMeasure == "Y",
                        render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

                      }],
                      [{
                        key: 'transitMeasureDeviationRate', label: 'label_transfer_measure_deviation_rate', formType: 'text',
                        if: (data) => data.isTransitMeasure == "Y",formatter: (r, c, v, i) => this.$addUnit(v ? v : "0", "%")
                      },],
                    ]
                  },
                },
                {
                  span: 12,
                  col: {
                    key: 'check_dimension', if: (data) => data.isTransitMeasure == "Y",
                    label: 'label_transfer_measure_dimen', 'width': 220, render: (h, { data }) => {
                      if ([data.transitMeasureSkuWeight, data.transitMeasureSkuLength, data.transitMeasureSkuWidth, data.transitMeasureSkuHeight].every(it => !it)) return this.$renderText(h, null)
                      return (<div>
                        <div>{this.$tt("label_weight") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuWeight, 3), "kg"))}</div>
                        <div>{this.$tt("label_length") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuLength, 2), "cm"))}</div>
                        <div>{this.$tt("label_width") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuWidth, 2), "cm"))}</div>
                        <div>{this.$tt("label_height") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuHeight, 2), "cm"))}</div>
                        <div>{this.$tt("label_volume") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(data.transitMeasureSkuVolume, 3), "m³"))}</div>

                      </div>)
                    }
                  },
                },]
              ],
            },
            { divider: true, },
            {
              grid: [[
                {
                  span: 12,
                  col: {
                    grid: [
                      [{
                        key: 'isOverseasMeasure', label: 'label_is_standard_measure', formType: 'text',
                        formatter: (r, c, v, i) => this.$enumShow(v ? v : "N", "YesOrNoEnum")
                      }],
                      [{
                        key: 'overseasMeasureTime', label: 'label_standard_measure_time', formType: 'text', if: (data) => data.isOverseasMeasure == "Y",
                        render: (h, { data, item }) => this.$renderText(h, this.$dateFormat(data[item.key]))

                      }],
                      [{
                        key: 'overseasMeasureDeviationRate', label: 'label_standard_measure_deviation_rate', formType: 'text',
                        if: (data) => data.isOverseasMeasure == "Y",formatter: (r, c, v, i) => this.$addUnit(v ? v : "0", "%")
                      }],
                    ],
                  }
                },
                {
                  span: 12,
                  col: {
                    key: 'check_dimension', if: (data) => data.isOverseasMeasure == "Y",
                    label: 'label_standard_measure_dimen', 'width': 220, render: (h, { data }) => {
                      const row = data
                      if ([row.overseasMeasureSkuWeight, row.overseasMeasureSkuLength, row.overseasMeasureSkuWidth, row.overseasMeasureSkuHeight].every(it => !it)) return this.$renderText(h, null)
                      return (<div>
                        <div>{this.$tt("label_weight") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuWeight, 3), "kg"))}</div>
                        <div>{this.$tt("label_length") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuLength, 2), "cm"))}</div>
                        <div>{this.$tt("label_width") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuWidth, 2), "cm"))}</div>
                        <div>{this.$tt("label_height") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuHeight, 2), "cm"))}</div>
                        <div>{this.$tt("label_volume") + " : " }{ this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuVolume, 3), "m³"))}</div>
                      </div>)
                    }
                  },
                },]
              ],
            },
            { divider: true, },
            {
              key: 'disposeMode', label: 'label_do_with_method', type: 'select',
              enum: 'SkuDifferenceDisposeModeEnum',
            },
            {
              key: 'coverMode', label: 'label_data_over_method', type: 'select', if: (data) => data.disposeMode != null && data.disposeMode != "ORIGINAL",
              enum: 'SkuDifferenceCoverModeEnum',
            },
            {
              key: 'attachedList', label: 'label_handler_attachment', type: 'ex_super_upload',
              attrs: {
                type: "file",
                limit: 10,
              }
            },
          ],
          rules: {
            'disposeMode': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            'coverMode': { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
            // 'attachedList': { type: "array", required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
          },
        }
      },
    };
  },
  methods: {
    option_table_model() {
      return [
        { type: 'selection', clickToggle: true, keyGroup: 'label_table_operate' },

        { key: 'receivingOrderCode', label: 'label_inbound_code', 'min-width': 200, 'show-overflow-tooltip': true, },
        { key: 'customerName', label: 'label_customer_name', 'width': 100, 'show-overflow-tooltip': true, },
        { key: 'customerCode', label: 'label_customer_code', 'width': 100, 'show-overflow-tooltip': true, },
        { key: 'skuOnlyCode', label: 'label_sku_only_code', 'width': 120, 'show-overflow-tooltip': true, },
        { key: 'skuName', label: 'label_sku_name', 'width': 120, 'show-overflow-tooltip': true, },

        {
          key: 'status', label: 'label_status', 'width': 140, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "SkuDifferenceStatusEnum")
        },


        {
          key: 'coverMode', label: 'label_data_over_method', 'width': 140, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, this.$enumShow(row[column.property], "SkuDifferenceCoverModeEnum"))

        },
        {
          key: 'deviationRate', label: 'label_record_deviation_rate', 'width': 120, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$addUnit(v ? v : "0", "%")
        },

        {
          key: 'dimension',
          label: 'label_filing_dimension', 'width': 220, render: (h, { row }) => {
            if ([row.skuWeight, row.skuLength, row.skuWidth, row.skuHeight].every(it => !it)) return this.$renderText(h, null)
            return (<div>
              <div>{this.$t("label_weight") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuWeight, 3), "kg"))}</div>
              <div>{this.$t("label_length") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuLength, 2), "cm"))}</div>
              <div>{this.$t("label_width") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuWidth, 2), "cm"))}</div>
              <div>{this.$t("label_height") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuHeight, 2), "cm"))}</div>
              <div>{this.$t("label_volume") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuVolume, 3), "m³"))}</div>
            </div>)
          }
        },
        {
          key: 'isTransitMeasure', label: 'label_is_transfer_measure', 'width': 120, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v ? v : "N", "YesOrNoEnum")
        },
        {
          key: 'transitMeasureTime', label: 'label_transfer_measure_time', 'width': 120, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, this.$dateFormat(row[column.property]))

        },
        {
          key: 'check_dimension',
          label: 'label_transfer_measure_dimen', 'width': 220, render: (h, { row }) => {
            if ([row.transitMeasureSkuWeight, row.transitMeasureSkuLength, row.transitMeasureSkuWidth, row.transitMeasureSkuHeight].every(it => !it)) return this.$renderText(h, null)
            return (<div>
              <div>{this.$tt("label_weight") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.transitMeasureSkuWeight, 3), "kg"))}</div>
              <div>{this.$tt("label_length") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.transitMeasureSkuLength, 2), "cm"))}</div>
              <div>{this.$tt("label_width") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.transitMeasureSkuWidth, 2), "cm"))}</div>
              <div>{this.$tt("label_height") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.transitMeasureSkuHeight, 2), "cm"))}</div>
              <div>{this.$tt("label_volume") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.transitMeasureSkuVolume, 3), "m³"))}</div>

            </div>)
          }
        },
        {
          key: 'transitMeasureDeviationRate', label: 'label_transfer_measure_deviation_rate', 'width': 120, 'show-overflow-tooltip': true,

          render: (h, { row, column }) => this.$renderText(h, this.$addUnit(row[column.property], "%"))

        },

        {
          key: 'isOverseasMeasure', label: 'label_is_standard_measure', 'width': 120, 'show-overflow-tooltip': true,

          render: (h, { row, column }) => this.$renderText(h, this.$enumShow(row[column.property] ? row[column.property] : "N", "YesOrNoEnum"))

        },
        {
          key: 'overseasMeasureTime', label: 'label_standard_measure_time', 'width': 120, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, this.$dateFormat(row[column.property]))

        },
        {
          key: 'check_dimension',
          label: 'label_standard_measure_dimen', 'width': 220, render: (h, { row }) => {
            if ([row.overseasMeasureSkuWeight, row.overseasMeasureSkuLength, row.overseasMeasureSkuWidth, row.overseasMeasureSkuHeight].every(it => !it)) return this.$renderText(h, null)
            return (<div>
              <div>{this.$tt("label_weight") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuWeight, 3), "kg"))}</div>
              <div>{this.$tt("label_length") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuLength, 2), "cm"))}</div>
              <div>{this.$tt("label_width") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuWidth, 2), "cm"))}</div>
              <div>{this.$tt("label_height") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuHeight, 2), "cm"))}</div>
              <div>{this.$tt("label_volume") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.overseasMeasureSkuVolume, 3), "m³"))}</div>

            </div>)
          }
        },
        {
          key: 'overseasMeasureDeviationRate', label: 'label_standard_measure_deviation_rate', 'width': 120, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, this.$addUnit(row[column.property], "%"))

        },


        {
          key: 'disposeMode', label: 'label_do_with_method', 'width': 140, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, this.$enumShow(row[column.property], "SkuDifferenceDisposeModeEnum"))

        },
        {
          key: 'disposeUserName', label: 'label_handler_user', 'width': 140, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, (row[column.property]))

        },
        {
          key: 'disposeTime', label: 'label_handler_time', 'width': 140, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, this.$dateFormat(row[column.property]))

        },

        {
          key: 'confirmUserName', label: 'label_confirm_user', 'width': 140, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, (row[column.property]))

        },
        {
          key: 'confirmTime', label: 'label_confirm_time', 'width': 140, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, this.$dateFormat(row[column.property]))

        },

        {
          key: 'closeUserName', label: 'label_close_user', 'width': 140, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, (row[column.property]))

        },
        {
          key: 'closeTime', label: 'label_close_time', 'width': 140, 'show-overflow-tooltip': true,
          render: (h, { row, column }) => this.$renderText(h, this.$dateFormat(row[column.property]))

        },
        {
          type: 'operate', width: 170, fixed: 'right', operate: [

            {
              label: 'label_view_detail', click: (row) => {
                this['$refs']['detailDialog'].showNew({
                  title: this.$tt("label_detail"),
                  params: {
                    id: row.id
                  },
                })
              }
            },
            {
              type: 'more',
              items: [
                {
                  label: 'label_deviation_handler', auth: 'oms_sku_measure_deviation_handler',

                  disabled: (row) => !['WAIT_DISPOSE'].includes(row.status),
                  click: (row) => {
                    this['$refs']['deviationHandlerDialog'].showNew({
                      title: this.$tt("label_deviation_handler"),
                      data: Object.assign({ attachedList: [] }, row),
                      onlySetData: true,
                    })
                  }
                },
                {
                  label: 'label_deviation_confirm', auth: 'oms_sku_measure_deviation_confirm',
                  disabled: (row) => !['WAIT_CONFIRM'].includes(row.status),
                  click: (row) => {
                    this.operateConfirm(row)
                  }
                },
                {
                  label: 'label_deviation_close', auth: 'oms_sku_measure_deviation_close',
                  disabled: (row) => !['WAIT_CONFIRM', "WAIT_DISPOSE"].includes(row.status),
                  click: (row) => {
                    this.operateClose(row)
                  }
                },
              ]
            }
          ]
        }
      ]
    },


    operateConfirm(row) {
      this.$confirm(this.$tt('tip_confirm_sure_sku_measure_difference', { sku: row.skuName }), this.$tt('label_tip'), {
        type: 'warning'
      }).then(() => {
        this.$ajax({
          url: "/oms-api/anomaly/OmsBaseSkuDifferenceRpc/confirm.json",
          method: 'post', type: "json",
          loading: true,
          data: {
            id: row.id
          },
          success: (res) => {
            this.$message({
              showClose: true,
              message: this.$tt('tip_submit_success'),
              type: 'success'
            })
            this.reload()
          }
        })
      }).catch(() => {
      });

    },
    operateClose(row) {
      this.$confirm(this.$tt('tip_confirm_close_sku_measure_difference', { sku: row.skuName }), this.$tt('label_tip'), {
        type: 'warning'
      }).then(() => {
        this.$ajax({
          url: "/oms-api/anomaly/OmsBaseSkuDifferenceRpc/close.json",
          method: 'post', type: "json",
          loading: true,
          data: {
            id: row.id
          },
          success: (res) => {
            this.$message({
              showClose: true,
              message: this.$tt('tip_submit_success'),
              type: 'success'
            })
            this.reload()
          }
        })
      }).catch(() => {
      });

    },


    exportExcel() {

      business_function.confirmOperateBaseSelectOrForm.call(this, {
        data: this.$refs.SuperTablePage.getSearchFormData(),
        model: this.option.search.model,
        callback: (selection, data) => {
          let params = data
          this.$functionCommon({
            url: "/oms-api/anomaly/OmsBaseSkuDifferenceRpc/export.json",
            data: params, type: 'form',
          })
        }
      })

    },
  }
};

</script>
<style></style>
